import request from '@/utils/request'

/**
 * 试卷管理相关接口
 */

export default {
  /**
   * 获取试卷列表
   * @param {Object} params 查询参数 {name, type, status, page, page_size}
   * @returns Promise
   */
  getExamList(params) {
    return request({
      url: '/teacher/papers',
      method: 'get',
      params
    })
  },

  /**
   * 获取试卷题目列表
   * @param {Object} params 查询参数 {type, status, page, page_size}
   * @returns Promise
   */
  getPaperQuestions(params) {
    return request({
      url: '/teacher/papers-questions',
      method: 'get',
      params
    })
  },

  /**
   * 新增试卷
   * @param {Object} data 试卷数据 {name, duration, type, status, question_ids}
   * @returns Promise
   */
  createExam(data) {
    return request({
      url: '/teacher/papers',
      method: 'post',
      data
    })
  },

  /**
   * 编辑试卷
   * @param {Object} data 试卷数据 {id, name, duration, type, status, question_ids}
   * @returns Promise
   */
  updateExam(data) {
    return request({
      url: '/teacher/papers',
      method: 'put',
      data
    })
  },

  /**
   * 删除试卷
   * @param {Number} id 试卷ID
   * @returns Promise
   */
  deleteExam(id) {
    return request({
      url: `/teacher/papers/${id}`,
      method: 'delete'
    })
  }
}